﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Manager;
using UnityEngine;

public class SceneAvatarBase
{

    public GameObject actorGO;

    private bool _initState;
    public bool initState
    {
        get
        {
            return _initState;
        }
    }

    public AvatarBaseVo vo;

    private string assetbundlePath = null;

    public void Init(AvatarBaseVo _vo)
    {
        vo = _vo;
        _initState = false;
        assetbundlePath =  AppConst.GetActorAssetBundlePath(vo.assetbundleName);
        GameManager.instance.resourceManager.LoadAssetBundle(
           assetbundlePath,
            null,
            () => {
                AssetBundle ab = GameManager.instance.resourceManager.GetAssetBundle(assetbundlePath);
                object obj = ab.LoadAsset(vo.assetbundleName.ToLower());
                actorGO = GameObject.Instantiate(obj as GameObject);
                actorGO.transform.SetParent(GameManager.instance.transform);
                actorGO.transform.position = new Vector3(5.5f, 0, 1.2f);
                actorGO.transform.rotation = Quaternion.Euler(new Vector3(0, 180, 0));
                GameManager.instance.resourceManager.RemoveAssetBundle(assetbundlePath,false);
                OnInitComplete();
                _initState = true;
            }
            );
    }

    /// <summary>
    /// 初始化完成
    /// </summary>
    protected virtual void OnInitComplete()
    {
       
    }

}
